//
//  ApplicationDelegate.m
//  Group Context
//
//  Created by Chris Karr on 2/13/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "ApplicationDelegate.h"

@implementation ApplicationDelegate

- (ApplicationDelegate *) init
{
	if (self = [super init])
	{
		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableUpdate:) name:TABLE_UPDATE object:nil];
		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusUpdate:) name:STATUS_UPDATE object:nil];
	}
	
	return self;
}

- (IBAction) refresh:(id) sender
{
	[[NSNotificationCenter defaultCenter] postNotificationName:UPDATE_STATUS object:self];
}

- (void) awakeFromNib
{
	[self refresh:nil];
}

- (void) tableUpdate:(NSNotification *) notification
{
	[tableView reloadData];
	[tableView setNeedsDisplay:YES];
	
	[window setTitle:[[notification userInfo] valueForKey:TITLE]];
	[window display];
}

- (void) statusUpdate:(NSNotification *) notification
{
	[status setStringValue:[[notification userInfo] valueForKey:STATUS]];
}

- (IBAction) preferences:(id) sender
{
	[preferences makeKeyAndOrderFront:sender];
}


@end
